import java.util.Observable;

	/**
	 * Upon notification, first lists the drivers and asks the user to pick one by
	 * specifying its ID. If the driver's ID is valid, then the deliveries made
	 * by that driver are listed.
	 * 
	 * @author Mathieu St-Jean
	 * @version 1.0 13/06/28
	 */

	/*
	 * Modification Log **********************************************************
	 * v1.0, Mathieu St-Jean, 13/06/28 - Original version.
	 * ***************************************************************************
	 */

	public class ListDriverDeliveriesMade extends Communication {

		public ListDriverDeliveriesMade(Integer registrationNumber,
				String componentName) {
			super(registrationNumber, componentName);
		}

		/**
		 * The update() method is an abstract method that is called whenever the
		 * notifyObservers() method is called by the Observable class. First we
		 * check to see if the NotificationNumber is equal to this thread's
		 * RegistrationNumber. If it is, then we execute.
		 * 
		 * @see ca.etsmtl.log430.lab3.Communication#update(java.util.Observable,
		 *      java.lang.Object)
		 */
		public void update(Observable thing, Object notificationNumber) {
			Menus menu = new Menus();
			Displays display = new Displays();
			Driver myDriver = new Driver();

			if (registrationNumber.compareTo((Integer) notificationNumber) == 0) {
				/*
				 * First we use a Displays object to list all of the drivers. Then
				 * we ask the user to pick a driver using a Menus object.
				 */
				addToReceiverList("ListDriversComponent");
				signalReceivers("ListDriversComponent");
				myDriver = menu.pickDriver(CommonData.theListOfDrivers
						.getListOfDrivers());

				/*
				 * If the user selected an invalid driver, then a message is
				 * printed to the terminal.
				 */
				if (myDriver != null) {
					display.displayDeliveriesMade(myDriver);
				} else {
					System.out.println("\n\n *** Driver not found ***");
				}
			}
			removeFromReceiverList("ListDriversComponent");
		}
	}
